<?php
/***
	投标项目数据模型。
	get_code_name () 获取所有编号和项目名。
**/
class Bid_project_model extends CI_Model {
	
	public function __construct() {
		$this->load->database();
	}
	
	
	public function get_code_name() {
		
		$sql = "select id, code, name from projects ORDER BY code DESC";
		$query = $this->db->query($sql);
		return $query->result_array();
	}
	
	public function get_by_id_code_name($id) {
		
		$sql = "select id, code, name from projects where id = '".$id."' ORDER BY code DESC";
		$query = $this->db->query($sql);
		return $query->row_array();
	}
	
	
	
	//以下没修改，不能直接使用
	
	//查询所有
	public function get_all() {
		
		$query = $this->db->get('type');
		return $query->result_array();
	}
	
	
	//通过code查询
	public function get_by_code($code) {
		$query = $this->db->get_where('type', array('code' => $code));
		return $query->row_array();
	}
	
	
	
	//修改
	public function edit ($code) {
		$data = array(
			'des' => $this->input->post('des'),			
		);
		
		$this->db->where('code', $code);
		$this->db->update('type', $data);
	}
	
	//删除
	public function del ($code) {
		$this->db->delete('type', array('code' => $code));
		
	}
	
}